package model.impl.menu;

import java.util.LinkedList;
import java.util.List;

import model.impl.StateListener;


abstract class AbstractMenuState implements IMenuState {
	protected int currentAlternative;
	protected int numberOfAlternatives;
	protected List<StateListener> listeners = new LinkedList<StateListener>();
	
	@Override
	public void addStateListener(StateListener listener) {
		listeners.add(listener);
	}
	
	@Override
	public void nextAlternative() {
		currentAlternative++;
		currentAlternative %= numberOfAlternatives;
	}

	@Override
	public void previousAlternative() {
		currentAlternative--;
		currentAlternative += numberOfAlternatives;
		currentAlternative %= numberOfAlternatives;
	}

	@Override
	public int getMarkedAlternative() {
		return currentAlternative;
	}
	
	@Override
	public void resetMarkedAlternativePosition() {
		currentAlternative = 0;
	}
}
